package org.cytoscape.cytargetlinker.internal;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.JOptionPane;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.model.CyNetwork;


public class CTLDialogAction extends AbstractCyAction {

	private CyApplicationManager applicationManager;
	private CySwingApplication swingApplication;
	private CTLManager manager;
	
	public CTLDialogAction(CyApplicationManager applicationManager, CTLManager manager, CySwingApplication swingApplication) {
		super("Load interaction data");
		setPreferredMenu("Apps.CyTargetLinker");
		this.applicationManager = applicationManager;
		this.manager = manager;
		this.swingApplication = swingApplication;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		List<CyNetwork> networks = applicationManager.getSelectedNetworks();
		
		/**
		 * at least one network has to be open
		 */
		if (networks != null && networks.size() > 0) {
			manager.openDialog();
		} else {
			JOptionPane.showMessageDialog(swingApplication.getJFrame(), "No network in current session.", "Warning", JOptionPane.WARNING_MESSAGE);
		}
	}

}
